package ro.gateway.aida.locations;

import org.apache.struts.action.ActionForm;

import ro.gateway.aida.obj.CRegion;
import ro.gateway.aida.obj.Country;
import ro.gateway.aida.obj.County;
import ro.gateway.aida.obj.Region;
import ro.gateway.aida.obj.Town;
import ro.gateway.aida.obj.Village;


/**
 * <p>Title: Romanian AIDA</p> <p>Description: </p> <p>Copyright: Copyright (comparator) 2003</p> <p>Company:
 * ro-gateway</p>
 *
 * @author Mihai Popoaei, mihai_popoaei@yahoo.com, smike@intellisource.ro
 * @version 1.0-* @version $Id: LocationEditorForm.java,v 1.1 2004/10/24 23:37:41 mihaipostelnicu Exp $
 */
public class LocationEditorForm extends ActionForm {
     public Village village;
     public Town town;
     public County county;
     public Region region;
     public Country country;
     public CRegion cregion;
     public Village villages[];
     public Town towns[];
     public County counties[];
     public Region regions[];
     public Country countries[];
     public CRegion cregions[];
     public int cregion_id = -1;
     public String country_iso3;
     public int region_id = -1;
     public int county_id = -1;
     public int town_id = -1;
     public int village_id = -1;

     public String action;


     public int getCregion_id() {
          return cregion_id;
     }

     public void setCregion_id( int cregion_id ) {
          this.cregion_id = cregion_id;
     }

     public String getCountry_iso3() {
          return country_iso3;
     }

     public void setCountry_iso3( String country_iso3 ) {
          this.country_iso3 = country_iso3;
     }

     public int getRegion_id() {
          return region_id;
     }

     public void setRegion_id( int region_id ) {
          this.region_id = region_id;
     }

     public int getCounty_id() {
          return county_id;
     }

     public void setCounty_id( int county_id ) {
          this.county_id = county_id;
     }

     public int getTown_id() {
          return town_id;
     }

     public void setTown_id( int town_id ) {
          this.town_id = town_id;
     }

     public int getVillage_id() {
          return village_id;
     }

     public void setVillage_id( int village_id ) {
          this.village_id = village_id;
     }

     public Village getVillage() {
          return village;
     }

     public void setVillage( Village village ) {
          this.village = village;
     }

     public Town getTown() {
          return town;
     }

     public void setTown( Town town ) {
          this.town = town;
     }

     public County getCounty() {
          return county;
     }

     public void setCounty( County county ) {
          this.county = county;
     }

     public Region getRegion() {
          return region;
     }

     public void setRegion( Region region ) {
          this.region = region;
     }

     public Country getCountry() {
          return country;
     }

     public void setCountry( Country country ) {
          this.country = country;
     }

     public CRegion getCregion() {
          return cregion;
     }

     public void setCregion( CRegion cregion ) {
          this.cregion = cregion;
     }

     public String getAction() {
          return action;
     }

     public void setAction( String action ) {
          this.action = action;
     }

     public Village[] getVillages() {
          return villages;
     }

     public void setVillages( Village[] villages ) {
          this.villages = villages;
     }

     public Town[] getTowns() {
          return towns;
     }

     public void setTowns( Town[] towns ) {
          this.towns = towns;
     }

     public County[] getCounties() {
          return counties;
     }

     public void setCounties( County[] counties ) {
          this.counties = counties;
     }

     public Region[] getRegions() {
          return regions;
     }

     public void setRegions( Region[] regions ) {
          this.regions = regions;
     }

     public Country[] getCountries() {
          return countries;
     }

     public void setCountries( Country[] countries ) {
          this.countries = countries;
     }

     public CRegion[] getCregions() {
          return cregions;
     }

     public void setCregions( CRegion[] cregions ) {
          this.cregions = cregions;
     }

     public void clear() {
          this.cregion = null;
          this.country = null;
          this.region = null;
          this.county = null;
          this.town = null;
          this.village = null;

          this.cregions = null;
          this.countries = null;
          this.regions = null;
          this.counties = null;
          this.towns = null;
          this.villages = null;

          this.cregion_id = -1;
          this.country_iso3 = null;
          this.region_id = -1;
          this.county_id = -1;
          this.town_id = -1;
          this.village_id = -1;
     }

     public String getParametersForEditor() {
          StringBuffer sb = new StringBuffer();

          if ( village != null ) {
               return sb.append( "action=chgvillage&village_id=" ).append( village_id ).toString();
          }
          if ( town != null ) {
               return sb.append( "action=chgtown&town_id=" ).append( town_id ).toString();
          }
          if ( county != null ) {
               return sb.append( "action=chgcounty&county_id=" ).append( county_id ).toString();
          }
          if ( region != null ) {
               return sb.append( "action=chgregion&region_id=" ).append( region_id ).toString();
          }
          if ( country != null ) {
               return sb.append( "action=chgcountry&country_iso3=" ).append( country_iso3 ).toString();
          }
          if ( cregion != null ) {
               return sb.append( "action=chgcregion&cregion_id=" ).append( cregion_id ).toString();
          }

          return sb.toString();
     }
}
